﻿using System;
using System.Threading;
using System.Windows.Forms;
using ProxyTool.Forms;
using ProxyTool.Services;

namespace ProxyTool
{
    internal static class Program
    {
        /// <summary>
        ///     应用程序的主入口点。
        /// </summary>
        [STAThread]
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += Application_ThreadException;
            Application.Run(new MainForm());
        }

        private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            if (e.Exception is ServiceException)
            {
                var serviceException = e.Exception as ServiceException;
                var exceptionForm = new ServiceExceptionForm(serviceException);
                exceptionForm.ShowDialog();
            }
            else
            {
                MessageBox.Show(e.Exception.Message, "异常提醒");
            }
        }
    }
}